<?php

    // +----------------------------------------------------------------------
    // | 推荐位模型
    // +----------------------------------------------------------------------
    // | Copyright (c) 2015-2024 http://www.yicmf.com, All rights reserved.
    // +----------------------------------------------------------------------
    // | Author: 微尘 <yicmf@qq.com>
    // +----------------------------------------------------------------------

    namespace app\model\cms;

    class PositionData extends Common
    {
        /**
         * 根据推荐位id获取文档列表
         * @param int|array   $map
         * @param int         $category_id 调用栏目ID
         * @param string|null $order       排序例如
         * @param int|null    $num         每次返回数据量
         */
        public static function getListsByPosition($map, $category_id = 0, $order = null, $num = 0)
        {
            $position = Position::get($map);
            return self::where('position_id', $position['id'])->order('create_time DESC')->select();
        }

        /**
         * 删除推荐数据，唯一文档id
         */
        public static function removeByDocumentId($document_id)
        {
            if ( !$document_id ) {
                return false;
            }
        }

        /**
         * 关联定义
         */
        public function position()
        {
            return $this->belongsTo('Position');
        }

		/**
		 * 写入修改
		 * @param $data
		 */
		public static function onBeforeInsert($data)
		{
			$data['status'] = 1;
		}

	}
